
//-------------------------
// Legislators as Lobbyists
// TABLE A2
//-------------------------

* Senate

clear
use masterdata_senate.dta

tabstat contactt, stat(N p25 p50 p75) 
gen group = .
replace group = 1 if contactt == 0
replace group = 2 if contactt > 0 & contactt<=2
replace group = 3 if contactt > 2

// generate demographic variables 

gen senior = (pop65to74 + pop75to84 + popover85)/population
gen whiteratio = white/population
gen blackratio = black/population
gen a1 = white/population
gen a2 = black/population
gen a3 = native/population 
gen a4 = asian/population
gen a5 = pacific/population
gen a6 = otherrace/population 
gen a7 = twomorerace/population
gen ethnic = 1 - (a1^2 + a2^2 + a3^2 + a4^2 + a5^2 + a6^2 + a7^2)
gen nohs = lessthanhs/pop_over25
gen hs = highschool/pop_over25 
gen loweredu = nohs + hs
gen college = bachelor/pop_over25
gen advanced = (master + professional + doctoral)/pop_over25
gen unemployment = pop_unemployed/pop_civilian

replace committee_chair = 0 if committee_chair == .
replace committee_chair = 1 if committee_chair == 2

gen sjuris = 0
replace sjuris = 1 if finance_trade_subcom == 1
replace sjuris = 1 if approp_labor_subcom == 1
replace sjuris = 1 if emply_wrk_safe_subcom == 1 

macro define member_char "democrat vote_share sjuris leadership majority_s pres_party_s"
macro define district_char "change_china_exp_s whiteratio loweredu unemployment"

by group, sort: sum $member_char $district_char 


* House

clear
use masterdata_house.dta

tabstat contactt, stat(N p25 p50 p75) 
gen group = .
replace group = 1 if contactt == 0
replace group = 2 if contactt > 0 & contactt<=2
replace group = 3 if contactt > 2

gen senior = (pop65to74 + pop75to84 + popover85)/population
gen whiteratio = white/population
gen blackratio = black/population
gen a1 = white/population
gen a2 = black/population
gen a3 = native/population 
gen a4 = asian/population
gen a5 = pacific/population
gen a6 = otherrace/population 
gen a7 = twomorerace/population
gen ethnic = 1 - (a1^2 + a2^2 + a3^2 + a4^2 + a5^2 + a6^2 + a7^2)
gen nohs = lessthanhs/pop_over25
gen hs = highschool/pop_over25 
gen loweredu = nohs + hs
gen college = bachelor/pop_over25
gen advanced = (master + professional + doctoral)/pop_over25
gen unemployment = pop_unemployed/pop_civilian

replace committee_chair = 0 if committee_chair == .
replace committee_chair = 1 if committee_chair == 2


gen hjuris = 0
replace hjuris = 1 if w_m_trade_subcom == 1
replace hjuris = 1 if approp_labor_subcom == 1
replace hjuris = 1 if wrkfrce_protec_subcom == 1 

macro define member_char "democrat vote_share hjuris leadership majority_h pres_party_h"
macro define district_char "change_china_exp whiteratio loweredu unemployment"

by group, sort: sum $member_char $district_char 




